import requests
from config.config import host1_1
import json
import sys
import urllib
#联盟链三方应用管理
class Thirdapp:
    #添加应用
    def add(self,payload):
        url=f'{host1_1}/thirdapp/add'
        res =requests.post(url,json=payload);
        return res
    #搜索
    def findAll(self,payload):
        url=f'{host1_1}/thirdapp/findAll'
        res=requests.post(url,data=payload)
        return res
    #修改
    def updateStatus(self,payload):
        url = f'{host1_1}/thirdapp/updateStatus'
        res=requests.post(url,data=payload)
        return res

if __name__ == '__main__':
    t = Thirdapp()
    #payload={"busiType": "1","name": "海数-测试","remark": ""} #传入的类型不存在时
    # 参数不存在
    #payload={"name": "海数-测试","remark": ""}  #busiType不存在
    #payload={"busiType": "1","remark": ""}  #name不存在
    #payload={"busiType": "1","name": "海数-测试"} #remark不存在
    #payload={} #都不存在

    #参数值为空
    #payload = {"busiType": "","name": "","remark": ""} #所有参数为空
    #payload = {"busiType": "","name": "测试","remark": ""} #类型为空
    #payload = {"busiType": "CPM","name": "","remark": ""} #名称为空


    # payload={"busiType": "123","name": "海数-测试","remark": ""}  #正常添加参数
    # res=t.add(payload) #添加
    # print(res.json())
    #payload={"page":1,"pageSize":10,"name":"ql","busiType":"CPM"}

    #根据名称搜索获取到id
    # payload = {"name": "ql"}
    # res = t.findAll(payload) #搜索
    # id=res.json()['data']['content'][0]['id']
    # print(res.json()['data']['content'][0]['id'])
    # #根据id修改状态
    #payload = {'id': 16}
    # payload={'id':16,"status":0}
    # res= t.updateStatus(payload)
    # print(res.json())

